{- Security.inc.orc -- Orc program Security.inc
 - 
 - $Id$
 - 
 - Created by akattepu on 07-Aug-2012 17:07:23
 -}

def bestQoS(comparer, publisher) = head(sortBy(comparer, publisher))
val curTime = Rclock()
type Level= String
def Level() = signal
def SecurityValue() = if (URandom() :> 0.5) then "High" else "Low"
 
-- Types and Definitions for Security
type SecurityLevel = String
def class SecurityLevel(unit) = 
  def QoS(String,String) :: String
  def QoS(sitex,security) =
    val k = Ref(0) 
    signal >>(k? >> Dictionary() >s> s.sitename := sitex >> s.sec := security >> s.sec?)
  
  def QoSOplus(String,String) :: String
  def QoSOplus(sl1,sl2) = Ift(sl1="High" && sl2="High") >> "High" |  Iff(sl1="High" && sl2="High") >> "Low"
  
  def QoSCompare(String,String) :: String
  def QoSCompare(sl1,sl2) = (sl1 = "High" && sl2="Low") 
  
  def QoSCompete(String,String) :: String
  def QoSCompete(sl1,sl2) = bestQoS(QoSCompare,[sl1,sl2])
  
  stop  
  